package fun.wlfj.AST;

import java.lang.annotation.Annotation;
import java.util.Optional;

import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.stmt.BlockStmt;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;

import junit.framework.Test;

public class TestMethodFinder extends VoidVisitorAdapter<Void> {
	
	MethodResolver resolver = new MethodResolver();
	
	@Override
	public void visit(MethodDeclaration md, Void v) {
		super.visit(md, v);
		
		// 现在我们要检查其前一个节点的信息是否包含@Test
		Optional<AnnotationExpr> testAnnotation = md.getAnnotationByClass((Class<? extends Annotation>) Test.class);
		if(testAnnotation.isPresent()) {
			Optional<BlockStmt> bs = md.getBody();
			if(bs.isPresent()) {
				resolver.visit(bs.get(), v);
			}
		}
		
	}
}
